<template>
	<view class="flex-col page">
		<view class="navbar" style="height:150rpx;width: 100vw; position: fixed;">
			<u-icon name="arrow-left" size="35" @click="back()"></u-icon>
			<text style="font-size: 36rpx;">我要反馈</text>
			<!-- <text style="font-size: 32rpx;" @click="go('/pages/my/setting/feedback/fackbacklist')">反馈记录</text> -->
			<text style="font-size: 32rpx ; width: 70px;" @click="goRecord">反馈记录</text>
		</view>
		<view class="flex-col group" style="margin-top: 130rpx;">
			<view class="flex-col">
				<view class="flex-col section_3">
					<text class="text_2">反馈类型</text>
					<view class="flex-col group_2">
						<view class="flex-row">
							<view class="flex-col items-center text-wrapper_1"
								v-bind:class="{ 'text-wrapper': isActive }"><text class="text_3"
									@click="setIndex(0)">下载/加载问题</text></view>
							<view class="flex-col items-center text-wrapper_1"
								v-bind:class="{ 'text-wrapper': isActive1 }"><text class="text_4"
									@click="setIndex(1)">会员付费问题</text></view>
							<view class="flex-col items-center text-wrapper_1"
								v-bind:class="{ 'text-wrapper': isActive2 }"><text class="text_4"
									@click="setIndex(2)">章节/图片问题</text></view>
						</view>
						<view class="flex-row group_4">
							<view class="flex-col items-center text-wrapper_1 "
								v-bind:class="{ 'text-wrapper': isActive3 }" @click="setIndex(3)"><text
									class="text_4">APP体验问题</text></view>
							<view class="flex-col items-center text-wrapper_1"
								v-bind:class="{ 'text-wrapper': isActive4 }" @click="setIndex(4)"><text
									class="text_4">卡顿/不流畅</text></view>
							<view class="flex-col items-center text-wrapper_1"
								v-bind:class="{ 'text-wrapper': isActive5 }" @click="setIndex(5)"><text
									class="text_4">其他</text></view>
						</view>
					</view>
				</view>
				<view class="flex-col section_4">
					<view class="flex-col items-start">
						<text class="text_10">反馈内容</text>
						<textarea v-model="form.details" placeholder-class="placeStyle"  placeholder="问题描述的越详细，有助于我们更快的解决问题" class="text_11"
							maxlength="200" />
					</view>
					<view class="flex-col items-start group_6">
						<shop-upload :maxCount='6' :fileList="fileList" @del="delectPic" @success='success'>
						</shop-upload>
						<text class="text_12">请上传应用截图，最多上传6张</text>
					</view>
				</view>
			</view>
			<view class="flex-col group_7">
				<view class="section_5">
					<!--*-->
				</view>
				<view class="flex-col items-center button" @click="submit"><text class="text_13">提交</text></view>
			</view>
		</view>
		<shop-check-login></shop-check-login>
	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				fileList: [],
				index: 0,
				isActive: false,
				isActive1: false,
				isActive2: false,
				isActive3: false,
				isActive4: false,
				isActive5: false,
				form: {
					details: '',
					feedbackPictures: '',
					feedbackType: 0,
					isActive: true,
					activeClass: 'active',
					errorClass: 'text-danger',
					activeColor: "green",

				}
			};
		},
		onLoad() {
			
			this.isActive = true
		},
		onShow() {
		this.index = 0	
		},
		methods: {
			// 跳转至反馈记录
			goRecord(){
				uni.navigateTo({
					url:'/pages/my/setting/feedback/fackbacklist'
				})
			},
			delectPic(index) {
				this.fileList.splice(index, 1);
			},
			success(file) {
				this.fileList.push({
					url: file.url
				})
			},
			setIndex(index) {
				if (index == 0) {
					this.isActive = true
				} else {
					this.isActive = false
				}
				if (index == 1) {
					this.isActive1 = true
				} else {
					this.isActive1 = false
				}
				if (index == 2) {
					this.isActive2 = true
				} else {
					this.isActive2 = false
				}
				if (index == 3) {
					this.isActive3 = true
				} else {
					this.isActive3 = false
				}
				if (index == 4) {
					this.isActive4 = true
				} else {
					this.isActive4 = false
				}
				if (index == 5) {
					this.isActive5 = true
				} else {
					this.isActive5 = false
				}
				this.form.feedbackType = index + 1;
			},
			submit() {
				if (this.form.details == '') {
					this.$u.toast('反馈内容不能为空');
					return;
				}
				let arr = [];
				this.fileList.map(item => {
					arr.push(item.url)
				})
				console.log(arr);
				this.form.feedbackPictures = arr.join(",");
				if (this.form.feedbackPictures == '') {
					this.$u.toast('请上传图片');
					return;
				}
				console.log(this.form.feedbackPictures);
				
				this.$http('feedback.saves', this.form).then(r => {
					if (r.code == 200) {
						this.form={}
						this.$u.toast(r.msg);
					} else {
						this.$u.toast(r.msg);
					}

				});
				this.go('/pages/my/setting/setting');
			},
			Back() {
				//uni.navigateBack()//默认delta:1
				uni.navigateBack({
					delta: 1, //返回层数，2则上上页
				})
			},

		},
	};
</script>

<style scoped lang="scss">
	/deep/ .u-icon__icon {
		width: 140rpx;
		
	}
	/deep/ .uni-textarea-textarea { 
		width: 686rpx;
		
	}
	.placeStyle {
		width: 686rpx;
	
	}
	.static {
		font-size: 30rpx;
	}

	.active {
		background-color: #007AFF;
	}

	.text-danger {
		font-size: 60rpx;
		color: #DD524D;
	}

	.navbar {
		// margin-top: 40rpx;
		box-sizing: border-box;
		padding: 40rpx 35rpx 0;
		height: 44px;
		background-color: #ffffff;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.text_11 {
		margin-top: 40rpx;
	}

	.text-wrapper_1 {
		margin-left: 16rpx;
		flex: 1 1 218rpx;
		padding: 15rpx 0 ;
		background-color: #f6f7f9;
		border-radius: 32rpx;
		align-items: center;
		// height: 64rpx;
		// line-height: 64rpx;
		color: #999999;
	}

	.text_4 {

		font-size: 28rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 33rpx;
		letter-spacing: -1.4rpx;
	}

	.page {
		background-color: #f6f7f9;
		width: 100%;
		overflow-y: auto;
		overflow-x: hidden;
		height: 100%;
	}

	.group {
		flex: 1 1 auto;
		overflow-y: auto;
	}

	.group_7 {
		margin-top: 248.5rpx;
		padding-top: 72rpx;
		position: relative;
	}

	.section_3 {
		padding: 25.5rpx 32rpx 32rpx;
		background-color: #ffffffff;
	}

	.section_4 {
		margin-top: 20rpx;
		padding: 29rpx 32rpx 40rpx;
		background-color: #ffffffff;
	}

	.section_5 {
		background-color: #ffffffff;
		height: 80rpx;
	}

	.button {
		padding: 19rpx 0 31rpx;
		background-color: #1d6aff;
		border-radius: 44rpx;
		position: absolute;
		left: 32rpx;
		right: 32rpx;
		top: 0;
	}

	.text_2 {
		align-self: flex-start;
		color: #1a1a1a;
		font-size: 32rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 38rpx;
		letter-spacing: -1.6rpx;
	}

	.group_2 {
		margin-top: 42rpx;
	}

	.group_6 {
		margin-top: 103rpx;
	}

	.group_4 {
		margin-top: 24rpx;
	}

	.text_10 {
		color: #1a1a1a;
		font-size: 32rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 38rpx;
		letter-spacing: -1.6rpx;
	}

	.text-wrapper {
		padding: 15rpx 0 21rpx;
		flex: 1 1 218rpx;
		border-radius: 32rpx;
		background: #e8f0ff;

		background-position: 0% 0%;
		background-size: 100% 100%;
		background-repeat: no-repeat;
		height: 64rpx;
		color: #1d6aff;
	}

	.view_2 {
		margin-left: 0;
	}

	.text_3 {

		font-size: 28rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 33rpx;
		/* letter-spacing: -1.4rpx; */
	}

	.text_13 {
		color: #ffffff;
		font-size: 32rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 38rpx;
	}

	.text_12 {
		margin-top: 21rpx;
		color: #bfbfbf;
		font-size: 24rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 28rpx;
		letter-spacing: -1.2rpx;
	}
</style>
